﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UpdateData.Util
{
    public class MyDate
    {
        /// <summary>
        /// 获取当前时间
        /// </summary>
        /// <returns></returns>
        public static string getDateTime()
        {
            return getDateToStr(DateTime.Now);
        }
        public static string getDateToStr(DateTime dt)
        {
            if (dt == null)
            {
                return "";
            }
            return dt.ToString("yyyy-MM-dd HH:mm:ss");
        }
        public static DateTime StrToDate(string dtStr)
        {
            DateTime dt = DateTime.Now;
            try
            {
                if (!string.IsNullOrEmpty(dtStr))
                {
                    dt = DateTime.Parse(dtStr);
                }
            }
            catch
            { }
            return dt;
        }
    }
}
